<%@page import="helpers.UrlHelper"%>
<%@page import="models.ConfigModel"%>
<%@page import="models.LinkModel"%>
<%@page import="models.CategoryModel"%>
<%@page import="java.util.ArrayList"%>
<%
	CategoryModel category = (CategoryModel) request.getAttribute("category");
	ArrayList<CategoryModel> categories = (ArrayList<CategoryModel>) request.getAttribute("categories");
	ArrayList<CategoryModel> parents = (ArrayList<CategoryModel>) request.getAttribute("parents");
	ArrayList<LinkModel> links = (ArrayList<LinkModel>) request.getAttribute("links");
	ConfigModel siteConfig = (ConfigModel) request.getAttribute("config");
	String image = UrlHelper.getServerUrl(request) + "/blobstore-serve?blob-key=" + siteConfig.getLogo();
%>
<jsp:include page="/layouts/header.jsp">
    <jsp:param name="title" value="<%=category.getName()%>" />
    <jsp:param name="description" value="<%=category.getMetaDesc()%>" />
    <jsp:param name="keywords" value="<%=category.getKeywords()%>" />
    <jsp:param name="ogsite_name" value="<%=siteConfig.getSiteName()%>" />
    <jsp:param name="ogtitle" value="<%=category.getName()%>" />
    <jsp:param name="ogurl" value="<%=siteConfig.getLayoutSiteUrl()%>" />
    <jsp:param name="ogimage" value="<%=image %>" />
    <jsp:param name="ogdescription" value="<%=category.getMetaDesc()%>" />
</jsp:include>
		<h2 class="title">Photography</h2>
		<div class="dir">
			<a href="/home">Directory</a>
			<% 
			for (int i = 0; i < parents.size(); i++) {
				if (i < parents.size() - 1) {
			%>
			 > <a href="/view-category/<%=parents.get(i).getId()%>"><%=parents.get(i).getName() %></a>
			<%	} else { %>
			 > <%=parents.get(i).getName() %>
			<% 
				}
			} %>
		</div>
		<% if (categories.size() > 0) { %>
		<div class="directories">
			<h2>Categories</h2>
			<table width="100%">
				<tr>
					<td>
						
						<ul>
							<% for (int i=0; i < (categories.size()/2 + categories.size()%2); i++) { %>
							<li><a href="/view-category/<%=categories.get(i).getId()%>"><%=categories.get(i).getName() %></a> (<%=categories.get(i).getCount() %>)</li>
							<% } %>
						</ul>
					</td>
					<td>
						<ul>
							<% 
							if (categories.size() > 1) {
								for (int i = (categories.size()/2 + categories.size()%2); i < categories.size(); i++ ) {
							%>
							<li><a href="/view-category/<%=categories.get(i).getId()%>"><%=categories.get(i).getName() %></a> (<%=categories.get(i).getCount() %>)</li>
							<% 
								}
							} %>
						</ul>
					</td>
				</tr>
			</table>
		</div>
		<br />
		<% } %>
		
		<% if (links.size() > 0) { %>
		<div class="links">
			<h2>Links</h2>
			<ul>
				<% for (int i = 0; i < links.size(); i++) { %>
				<li>
					<a href="<%=links.get(i).getUrl()%>"><%=links.get(i).getName() %></a>
					<br />
					<%=links.get(i).getDesc() %>
					<br />
					<font color="green">linkdirectory.com/category</font>
				</li>
				<% } %>
			</ul>
		</div>
		<% } %>
<jsp:include page="/layouts/footer.jsp">
    <jsp:param name="language" value="1" />
</jsp:include>